package com.sixth.controller;

import com.sixth.entity.Keycap;
import com.sixth.service.KeycapService;
import com.sixth.util.CommonResult;
import com.sixth.util.TableLayUi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: project01
 * @description:
 * @author: 老魏
 * @create: 2021-12-27 10:05
 **/
@RestController
@RequestMapping("/keycap")
public class KeycapController {
  @Autowired
    public KeycapService keycapService;

  @RequestMapping("/AllKeycap")
    public CommonResult getAllKeycap(){
      CommonResult commonResult = keycapService.findAlllKeycap();
      return  commonResult;
  }

  @RequestMapping("/addOrUpdate")
    public  CommonResult addOrUpdate(Keycap keycap){
      if(keycap.getKeycapid() !=null){
          return  keycapService.update(keycap);
      }else {
          return  keycapService.insert(keycap);
      }
  }
    @RequestMapping("/dalete")
    public  CommonResult delete(Integer keycap){
      return  keycapService.delete(keycap);
    }
    @RequestMapping("/listByCondition")
    public TableLayUi listByCondition(int page, int limit , String keycapid, String  keycapname){
      return  keycapService.findKeycapCondition(page,limit,keycapid,keycapname);
    }
}
